<template>
	<view class="content flexcc">
		<view style="margin: 0 100rpx;width: 550rpx;">
			<u--input style="width: 100%;margin-bottom: 20rpx;"
			    placeholder="请输入用户名"
			    border="surround"
			    v-model="all.mobile"
			  ></u--input>
			  <u--input style="width: 100%;margin-bottom: 20rpx;"
			      placeholder="请输入密码"
			      border="surround"
			      v-model="all.password" type="password"
			    ></u--input>
				<u-button type="primary" text="登录" @click="login"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				all:{
					mobile: "17616212620",
					password: ''
				}
			}
		},
		onShow() {
			
		},
		methods: {
			login:function(){
				uni.$u.http.post(this.urlass + '/api/v1/auth/login', this.all).then(res2 => {
							if (res2.data.code == 200) {
								uni.setStorageSync('token', res2.data.data.access_token)
								uni.setStorageSync('api_token', res2.data.data.api_token)
								uni.setStorageSync('person', JSON.stringify(res2.data.data))
								this.$nextTick(()=>{
									uni.redirectTo({
										url: '/pages/index/index',
									});
								})
							} else {
								this.$refs.uToast.show({
									message: "登录失败了",
									type: "error"
								})
							}
				})
			}
			
		}
	}
</script>

<style scoped lang="scss">
	.content{ width: 100vw;height: 100vh;}
	
</style>
